const express = require("express");
const app = express();

const mongoose = require("mongoose");
const redis = require("redis");
const bodyParser = require('body-parser');
const cors = require('cors');


app.use(express.static(__dirname + '/public'));
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({ limit: '50mb',extended: true }));

app.use(cors());



global.dbHelper = require( './db/dbHelper' );

//引入数据库文件
let connectDB = require("./db/connectDB");


global.enforcementDetail = global.dbHelper.getModel('enforcementDetail');

//连接mongodb

connectDB.mongoose(mongoose);

//连接redis

connectDB.redis(redis);


//引入封装好的方法
global.utils = require("./common/utils");



/*
 *@des getTitle 获取文章标题的接口
 *
 *@method   post请求
 */ 

let apiGetTitle = require("./api/apiGetTitle");

app.post("/getTitle",apiGetTitle.apiGetTitle);


app.listen(8000);



 
